package com.example.hissys.service;

import com.example.hissys.entity.Hospital;
import com.example.hissys.mapper.HospitalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import java.util.List;

/**
 * 医院服务层
 * @author Your Name
 * @since 2025-01-03
 */
@Service
@Slf4j
public class HospitalService {
    @Autowired
    private HospitalMapper hospitalMapper;

    /**
     * 获取所有医院列表
     * @return 医院列表
     */
    public List<Hospital> getAllHospitals() {
        log.info("Fetching all hospitals");
        return hospitalMapper.findAll();
    }

    /**
     * 根据ID获取医院信息
     * @param id 医院ID
     * @return 医院信息
     */
    public Hospital getHospitalById(Integer id) {
        log.info("Fetching hospital with id: {}", id);
        return hospitalMapper.findById(id);
    }

    /**
     * 搜索医院
     * @param keyword 搜索关键词
     * @return 匹配的医院列表
     */
    public List<Hospital> searchHospitals(String keyword) {
        log.info("Searching hospitals with keyword: {}", keyword);
        return hospitalMapper.searchByName(keyword);
    }

    /**
     * 根据等级获取医院列表
     * @param level 医院等级
     * @return 医院列表
     */
    public List<Hospital> getHospitalsByLevel(String level) {
        log.info("Fetching hospitals with level: {}", level);
        return hospitalMapper.findByLevel(level);
    }
} 